package xiangmu1;
import java.util.Scanner;
public class Test1 {
    public void fun(){
        //控制台输入
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String names = scanner.next();
        System.out.println("请输入密码：");
        int pass = scanner.nextInt();
        //对象初始化
        Test2 test2 = new Test2();

        //判断用户信息是否匹配
        if (names.equals(User1.user[0].getName())&&pass==User1.user[0].getPassed()){
            try{
                int n=0;
                do {
                    System.out.println("1.加入汽车"+"\n"+"2.下架汽车"+"\n"+"3.查看信息"+"\n"+"4.退出");
                    int num1 =scanner.nextInt();
                    switch (num1){
                        case 1:
                            //调用方法
                            test2.fun1();
                            break;
                        case 2:
                            test2.fun2();
                            break;
                        case 3:
                            test2.fun3();
                            break;
                        case 4:
                            n=1;
                            break;
                    }
                }while (n==0);
            }catch (Exception e){
                System.out.println("");
            }
        }else if (names.equals(User1.user[1].getName())&&pass==User1.user[1].getPassed()){
            int n=0;
            do {
                System.out.println("1.租车"+"\n"+"2.还车"+"\n"+"3.查看订单"+"\n"+"4.充值"+"\n"+"5.退出");
                int num2 = scanner.nextInt();
                switch (num2){
                    case 1:
                        test2.fun4();
                        break;
                    case 2:
                        test2.fun5();
                        break;
                    case 3:
                        test2.fun6();
                        break;
                    case 4:
                        test2.fun7();
                        break;
                    case 5:
                        n=1;
                        System.out.println("顾客慢走，欢迎下次再来");
                        break;
                }
            }while (n==0);
        }
        else {
            System.out.println("你输入的有误");
        }
    }
}

